using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_Profile_ValueMap : EntityTypeConfiguration<Tb_Profile_Value>
	{
		public Tb_Profile_ValueMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.code)
				.HasMaxLength(10);
				
			this.Property(t => t.option)
				.IsFixedLength()
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("Tb_Profile_Value");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.id_person).HasColumnName("id_person");
			this.Property(t => t.code).HasColumnName("code");
			this.Property(t => t.id_keyworkprofile).HasColumnName("id_keyworkprofile");
			this.Property(t => t.value).HasColumnName("value");
			this.Property(t => t.option).HasColumnName("option");

			// Relationships
			this.HasRequired(t => t.Tb_Config)
				.WithMany(t => t.Tb_Profile_Value)
				.HasForeignKey(d => d.id_keyworkprofile);
				
			this.HasRequired(t => t.Tb_People)
				.WithMany(t => t.Tb_Profile_Value)
				.HasForeignKey(d => d.id_person);
				
		}
	}
}

